#ifndef _MAP_
#define _MAP_
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <sstream>
#include "Object.h"
#include "Mario.h"


using namespace std;



class Map
{
private:
	//Mario *mario;
	LPDIRECT3DDEVICE9 _d3ddv;
	LPDIRECT3DSURFACE9 _backBuffer;
	LPD3DXSPRITE			_spriteHandler;	// SpriteHandler to draw texture
	
	int **mang_2_c;
	int width_map;
	int height_map;
	std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
	std::vector<std::string> split(const std::string &s, char delim);
public:
	Map(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, LPD3DXSPRITE SpriteHandler, MarioManager* game_Mario);
	void LoadMapFromFile(char* fileName);
	int GetWidth() { return width_map; }
	int GetHeight() { return height_map; }
	vector<Object*> GetObjects();

	vector<Object*> GetAllObjects(QuadTree *quadTree, MarioManager* game_Mario);
	void SaveMapToFile(char* fileName, QuadTree *quadTree, MarioManager* game_Mario);

	//fix map
	//Luu trang thai cua game khi save map
	int numScore;
	int numLife;
	int numCoin;
	bool isLoadSubMap;		//Kiem tra xem co load map phu hay khong?	
	bool isSubMap;			//Kiem tra co la map phu khong?

	Mario *saveMario;		//Luu trang thai cua mario khi chuyen map


	void LoadMap(char* fileName, QuadTree *quadTree, MarioManager* game_Mario);
	void SaveMap(char* fileName, QuadTree *quadTree, MarioManager* game_Mario);
	//list<Object*> GetObjects();
	//list<Object*> Map::GetObjectsCollision();
};

#endif 